#!/usr/bin/env ruby

def check_md5 file_path
  result = `md5sum -c #{file_path}.md5`
  result = /\: OK/m.match(result) ? "success":"fail" 
  `touch #{file_path}.md5.#{result}` 
end

puts "[#{Time.new}] Start"
require 'etc'
c=  Etc.getpwnam('neocoinn').dir
["#{c}/home/zeropage/backup/","#{c}/home/trimek/backup/"].each do|dir|
puts dir
  Dir.chdir dir
  Dir["*.md5"].each do |n|
puts 'process #{n}'
    check_md5 n[0...-4] if Dir["#{n}.*"].empty?
  end
end
puts "[#{Time.new}] End"
